//主页
import React, { Component } from 'react';
import {
    View,
    Text,
    TouchableOpacity,
} from 'react-native';

import { homethreeStyle as styles } from '../../../../styles';
import Icon from 'react-native-vector-icons/Ionicons';

import { EditResumeAction } from '../../../actions/systemAction';      //加载action
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';

var Dimensions = require('Dimensions');
var width = Dimensions.get('window').width;
var height = Dimensions.get('window').height;

class Homethree extends Component {
    // 初始化模拟数据
    constructor(props) {            //构造器只执行一次
        super(props);
    };

    //加载后渲染页面
    componentDidMount() {
        this.props.actions.EditResumeAction({}); //初始化查询
    }

    render() {
        return (
            <View style={styles.homethree}>

                {/* 职位 */}

                <TouchableOpacity
                    onPress={() => { this.props.navigation.navigate('Collectall') }}
                    activeOpacity={1} style={styles.homepoe}>
                    <View style={styles.homesmall}>
                        <Icon
                            name={'ios-rose'}
                            size={25}
                            color={'#fc6866'} style={styles.homepi} />
                        <Text style={styles.hometex}>职位</Text>
                    </View>
                    <Text style={styles.hometext}>订制你的职位</Text>
                </TouchableOpacity>

                <TouchableOpacity
                    onPress={() => { this.props.navigation.navigate('Resume') }}
                    activeOpacity={1} style={styles.homepoe}>
                    <View style={styles.homesmall}>
                        <Icon
                            name={'md-cog'}
                            size={23}
                            color={'#ffa500'} style={styles.homepi} />
                        <Text style={styles.hometex}>简历</Text>
                    </View>

                    <Text style={styles.hometext}>完善你的简历</Text>
                </TouchableOpacity>

                <TouchableOpacity onPress={() => { this.props.navigation.navigate('Newsall') }}
                    activeOpacity={1} style={styles.homepoe2}>
                    <View style={styles.homesmall}>
                        <Icon
                            name={'md-trophy'}
                            size={23}
                            color={'#3d9ccc'} style={styles.homepi} />
                        <Text style={styles.hometex}> 消息</Text>
                    </View>

                    <Text style={styles.hometext}>查看你的消息</Text>
                </TouchableOpacity>
            </View>


        )
    }
}

//组合action
var actions = {
    EditResumeAction,
}

//连接state到props
const mapStateToProps = state => {
    return {
        xz_resume: state.EditResumeReducer             //自己的reducers
    }
}

//连接action
const mapDispatchToProps = (dispatch) => {
    return {
        actions: bindActionCreators(actions, dispatch)
    }
}

//导出组合好的组件(组合后状态改变重新渲染组合组件的页面)
export default connect(
    mapStateToProps, mapDispatchToProps
)(Homethree);